home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / filestuf.lzh / EXAMPLE2.CMD < prev    next >
OS/2 REXX Batch file  |  1990-08-22  |  5KB  |  152 lines

  1. ;Example script 2...
  2. s
  3. s We're in the second example script now. You've seen how the ECHO command
  4. s can turn off the echo of file commands. I'm going to turn it back on now so
  5. s you can watch the command lines used in this demo.
  6. s
  7. e +
  8. b
  9. p 15
  10. s In this example script, we'll demonstrate Filestuff's File Commands.
  11. s Filestuff has the ability to copy, rename, or delete files, or to branch
  12. s if a particular file exists. If any errors occur in the process, you can
  13. s have Filestuff display an error message, branch to another part of the
  14. s script, or both. You can also ignore errors if you wish.
  15. s
  16. b
  17. p 18
  18. s Filestuff uses your ST's memory as a work area to hold both the script
  19. s you're running and any file you wish to copy. If you're interested in
  20. s finding out just how much work space is available, use the "?" command;
  21. s it will display the size of the work area in hexadecimal. The largest file
  22. s you can copy will be this size minus the size of the current script. Right
  23. s now, you have this much space available:
  24. s
  25. ? -- display work area size
  26. s
  27. b
  28. p 20
  29. s Now for the file commands. First, you can check for the existence of a
  30. s file and branch if it's found. Just to be sure, let's see if EXAMPLE2.CMD
  31. s is anywhere around (it should be, this is it!)...
  32. s
  33. fexists \example2.cmd 10  --  jump to label 10 if it's there
  34. s
  35. s     WHOOPS! The file isn't where it should be!
  36. s
  37. s Since I need the file handy to demonstrate the file commands, there's no
  38. s point in going any further. Please copy EXAMPLE2.CMD into the root
  39. s directory of your disk, then run this script again.
  40. s
  41. b
  42. p 30
  43. b
  44. quit
  45. ;------------------------
  46. @ 10
  47. s
  48. s Ok, found it right where it should be, in the root directory.
  49. b
  50. p 10
  51. s
  52. s Just for fun, let's check for a file you probably DON'T have...
  53. s
  54. f \whoopie.do! 20
  55. s
  56. s Nope, not there... I'm SOOO glad! <grin>
  57. j 25
  58. @ 20
  59. s
  60. s How strange, you p DO q have a file named WHOOPIE.DO!......
  61. s (I'm going to rename it now because I need the name later...)
  62. s
  63. ren \whoopie.do! \hah!moo!.<g>
  64. @ 25
  65. b
  66. p 10
  67. s
  68. s Anyway, on with the demo. First, I'm going to show you what you can do
  69. s if there's an error with a copy, rename, or delete command. I'll try to
  70. s make a copy of WHOOPIE.DO!, which you SHOULDN'T have around...
  71. s
  72. b
  73. p 10
  74. copy \whoopie.do! \hah.moo
  75. s
  76. s Now we can check for errors. To let Filestuff display its error message,
  77. s use the "Z" command p alone on the command line q, which results in a
  78. s display like this:
  79. s
  80. z
  81. s
  82. b
  83. p 11
  84. s You can use the "Z LABEL" form of the command to jump to your own error
  85. s routine instead of (or in addition to) having Filestuff's message...
  86. s
  87. z 29  --  jump to label 29 if there was an error
  88. s What, no error? You actually _had_ a WHOOPIE.DO! file?????
  89. j 30
  90. @ 29
  91. s Warning! Error! No WHOOPIE.DO! file found! Oh no! Woe is me! :-)
  92. @ 30
  93. s
  94. b
  95. p 11
  96. s
  97. s Ok, all that's really left are the file commands - the main reason for
  98. s having Filestuff in the first place! I'm going to start by making a few
  99. s copies of EXAMPLE2.CMD to work with. (Note that I'm starting with the copy
  100. s named TEST3 first, not with TEST1...)
  101. s
  102. copy \example2.cmd \test3
  103. c \example2.cmd \test2
  104. copythisfile \example2.cmd \test1
  105. s
  106. b
  107. p 20
  108. s Note that you only need to use the first character of the command; any
  109. s characters after the first are ignored.
  110. s
  111. s Next, I'm going to use the Delete command. I'll use a wildcard here just
  112. s to show you what happens - namely, the command will only affect the FIRST
  113. s matching filename, it WON'T delete all matching files!
  114. s
  115. del \tes*
  116. s
  117. b
  118. p 10
  119. s Right now you should have only TEST1 and TEST2 on your disk - the other
  120. s file, TEST3, should have been deleted. Why TEST3 and not TEST1? That's
  121. s because I created TEST3 _before_ TEST1... even though TEST1 comes first in
  122. s alphabetical order, TEST3 came first in your disk's directory. Remember
  123. s this if you decide to use wildcards in your scripts...
  124. s
  125. b
  126. p 20
  127. s Ok, the last command is the RENAME command. It's pretty simple. The only
  128. s thing to watch out for is to make sure that your file's new name isn't
  129. s already being used in that folder - if it is, you'll get an error.
  130. s
  131. ren \test2 \whoopie.do!
  132. s
  133. s Hah! Moo! I just KNEW you wanted a file with that name! <grin!>
  134. s
  135. b
  136. p 15
  137. s One more note - you can also use the Rename command to p move q a file
  138. s to a different folder on the same disk! One of GEMDOS's more convenient,
  139. s if less used, features.
  140. s
  141. b
  142. p 5
  143. s
  144. s Well, that's it for the tour! I hope you get some good use from
  145. s Filestuff. Send me a card and let me know how it works for you!
  146. s
  147. s    Bill Aycock
  148. s    August 22, 1990
  149. b
  150. p 20
  151. b
  152.